package academic.concordia.bankofquebec.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import academic.concordia.bankofquebec.bean.utils.CreditCardUtils;

@Entity
@Table(name="CreditCard")
public class CreditCard extends BankAccount implements Serializable {

	private static final long serialVersionUID = 1L;
	private Date expirationDate;
	private double minimunPayment;
	private double creditLimit;
	private String securityCode;
	private Date paymentDueDate;
	private int billingCycle;
	private double billingCycleBalance;
	private CreditCardDescription cardDescription;
	
	public CreditCard (){
		super();
		this.attributes = AccountAttributes.CREDIT_CARD;
		this.type = this.attributes.name();
		this.cardDescription = new CreditCardDescription();
		this.expirationDate = CreditCardUtils.getExpirationDate(this);
	}

	public Date getExpirationDate() {
		return expirationDate;
	}

	public void setExpirationDate(Date expirationDate) {
		this.expirationDate = expirationDate;
	}

	public double getMinimunPyament() {
		return minimunPayment;
	}

	public void setMinimunPyament(double minimunPyament) {
		this.minimunPayment = minimunPyament;
	}
	
	public double getCreditLimit() {
		return creditLimit;
	}

	public void setCreditLimit(double creditLimit) {
		this.creditLimit = creditLimit;
	}

	public String getSecurityCode() {
		return securityCode;
	}

	public void setSecurityCode(String securityCode) {
		this.securityCode = securityCode;
	}

	public Date getPaymentDueDate() {
		return paymentDueDate;
	}

	public void setPaymentDueDate(Date paymentDueDate) {
		this.paymentDueDate = paymentDueDate;
	}

	public double getBillingBalance() {
		return billingCycleBalance;
	}

	public void setBillingBalance(double billingBalance) {
		this.billingCycleBalance = billingBalance;
	}

	@ManyToOne
	@JoinColumn(name="Description")
	public CreditCardDescription getCardDescription() {
		return cardDescription;
	}

	public void setCardDescription(CreditCardDescription cardDescription) {
		this.cardDescription = cardDescription;
	}

	public int getBillingCycle() {
		return billingCycle;
	}

	public void setBillingCycle(int billingCycle) {
		this.billingCycle = billingCycle;
	}
	@Transient
	public boolean isPaymentAccount(){
		return true;
	}

}
